package cn.xzchain.concurrency.singleton;

import cn.xzchain.concurrency.annoations.NotThreadSafe;
import cn.xzchain.concurrency.annoations.ThreadSafe;
import lombok.extern.slf4j.Slf4j;

/**
 * @author lihang
 * @date 2018/5/7.
 * @description 饿汉模式--线程安全，可能导致资源浪费
 */
@ThreadSafe
public class Singleton2 {

    private Singleton2(){
    }

    private static Singleton2 instance = new Singleton2();


    /**静态工厂模式*/
    public static Singleton2 getInstance(){
        return instance;
    }
}
